package com.ruoyi.shopping.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.shopping.domain.CommodityLikeReply;
import com.ruoyi.shopping.service.ICommodityLikeReplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 回复点赞管理Controller
 * 
 * @author fxy
 * @date 2024-08-14
 */
@RestController
@RequestMapping("/shopping/LikeReply")
public class CommodityLikeReplyController extends BaseController
{
    @Autowired
    private ICommodityLikeReplyService commodityLikeReplyService;

    /**
     * 查询回复点赞管理列表
     */
    @PreAuthorize("@ss.hasPermi('shopping:LikeReply:list')")
    @GetMapping("/list")
    public TableDataInfo list(CommodityLikeReply commodityLikeReply)
    {
        startPage();
        List<CommodityLikeReply> list = commodityLikeReplyService.selectCommodityLikeReplyList(commodityLikeReply);
        return getDataTable(list);
    }

    /**
     * 导出回复点赞管理列表
     */
    @PreAuthorize("@ss.hasPermi('shopping:LikeReply:export')")
    @Log(title = "回复点赞管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CommodityLikeReply commodityLikeReply)
    {
        List<CommodityLikeReply> list = commodityLikeReplyService.selectCommodityLikeReplyList(commodityLikeReply);
        ExcelUtil<CommodityLikeReply> util = new ExcelUtil<CommodityLikeReply>(CommodityLikeReply.class);
        util.exportExcel(response, list, "回复点赞管理数据");
    }

    /**
     * 获取回复点赞管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('shopping:LikeReply:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(commodityLikeReplyService.selectCommodityLikeReplyById(id));
    }

    /**
     * 新增回复点赞管理
     */
    @PreAuthorize("@ss.hasPermi('shopping:LikeReply:add')")
    @Log(title = "回复点赞管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CommodityLikeReply commodityLikeReply)
    {
        return toAjax(commodityLikeReplyService.insertCommodityLikeReply(commodityLikeReply));
    }

    /**
     * 修改回复点赞管理
     */
    @PreAuthorize("@ss.hasPermi('shopping:LikeReply:edit')")
    @Log(title = "回复点赞管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CommodityLikeReply commodityLikeReply)
    {
        return toAjax(commodityLikeReplyService.updateCommodityLikeReply(commodityLikeReply));
    }

    /**
     * 删除回复点赞管理
     */
    @PreAuthorize("@ss.hasPermi('shopping:LikeReply:remove')")
    @Log(title = "回复点赞管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(commodityLikeReplyService.deleteCommodityLikeReplyByIds(ids));
    }
}
